package com.jun.basic.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class JsonData<T> {

    private int code;

    private T data;

    private String msg;

    public JsonData(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public static <T> JsonData<T> buildSuccess(T data) {
        return new JsonData<T>(0, data, "");
    }

    public static <T> JsonData<T> buildFail(String msg) {
        return new JsonData<T>(-1, null, msg);
    }

    public static <T> JsonData<T> buildFail(int code, String msg) {
        return new JsonData<T>(code, null, msg);
    }
}
